import { NextResponse } from "next/server"
import type { Comment } from "@/types/comment"

export async function POST(request: Request, { params }: { params: { commentId: string } }) {
  const commentId = Number.parseInt(params.commentId)
  const body = await request.json()
  const { contentId, contentType, content, userId } = body

  // Validate necessary parameters
  if (!contentId || !contentType || !content || !commentId) {
    return NextResponse.json(
      {
        code: 400,
        message: "Missing required parameters",
      },
      { status: 400 },
    )
  }

  // Create new reply
  const newReply: Comment = {
    id: Date.now(),
    user: {
      id: userId || "current-user", // In a real app, this should come from session
      name: "当前用户",
      avatar: "/placeholder.svg?height=40&width=40",
    },
    content,
    timestamp: new Date().toLocaleString("zh-CN", {
      year: "numeric",
      month: "numeric",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
    }),
    likes: 0,
    isLiked: false,
  }

  return NextResponse.json({
    code: 200,
    data: newReply,
  })
}

